import { axios } from '@/service/service'

export function createUserDbReq(params: any): any {
  return axios({
    url: '/api-dataManage/admin/createUserDatabase',
    method: 'get',
    params
  })
}

export function createProDbReq(params: any): any {
  return axios({
    url: '/api-dataManage/admin/createProDatabase',
    method: 'get',
    params
  })
}

export function setDbSizeReq(params: any): any {
  return axios({
    url: '/api-dataManage/admin/setDbSize',
    method: 'get',
    params
  })
}

export function addOrUpdateDatasourceReq(data: any): any {
  return axios({
    url: '/api-dataManage/datasource/addOrUpdate',
    method: 'post',
    data
  })
}

export function getDatasourceListReq(params: any): any {
  return axios({
    url: '/api-dataManage/datasource/findDatasources',
    method: 'get',
    params
  })
}

export function connTestReq(data: any): any {
  return axios({
    url: '/api-dataManage/datasource/connTest',
    method: 'post',
    data
  })
}

export function delDatasourceReq(id: number): any {
  return axios({
    url: `/api-dataManage/datasource/delete/${id}`,
    method: 'get'
  })
}

export function dropDatabaseReq(params: any): any {
  return axios({
    url: '/api-dataManage/dataCatalog/dropDatabase',
    method: 'get',
    params
  })
}

export function dropTableReq(params: any): any {
  return axios({
    url: '/api-dataManage/dataCatalog/dropTable',
    method: 'get',
    params
  })
}

export function createDatabaseReq(params: any): any {
  return axios({
    url: '/api-dataManage/dataCatalog/createDatabase',
    method: 'get',
    params
  })
}

export function createTableReq(data: any): any {
  return axios({
    url: '/api-dataManage/dataCatalog/createTable',
    method: 'post',
    data
  })
}

export function modTableReq(data: any): any {
  return axios({
    url: '/api-dataManage/dataCatalog/modifyTable',
    method: 'post',
    data
  })
}

export function syncMetaReq(id: number): any {
  return axios({
    url: `/api-dataManage/datasource/synch/${id}`,
    method: 'get'
  })
}

export function syncDbMetaReq(params: any): any {
  return axios({
    url: '/api-dataManage/dataCatalog/synchDatabase',
    method: 'get',
    params
  })
}
export function syncTableMetaReq(params: any): any {
  return axios({
    url: '/api-dataManage/dataCatalog/synchTable',
    method: 'get',
    params
  })
}

export function findAllDbTypesReq(): any {
  return axios({
    url: '/api-dataManage/datasource/findAllDbTypes',
    method: 'get'
  })
}

export function findDatasourcesByTypeReq(params: any): any {
  return axios({
    url: '/api-dataManage/dataCatalog/findDatasourcesByType',
    method: 'get',
    params
  })
}

export function findPublicDatabasesReq(params: any): any {
  return axios({
    url: '/api-dataManage/dataCatalog/findPublicDatabases',
    method: 'get',
    params
  })
}
export function findProDatabasesReq(): any {
  return axios({
    url: '/api-dataManage/dataCatalog/findProDatabases',
    method: 'get'
  })
}
export function findUserDatabasesReq(): any {
  return axios({
    url: '/api-dataManage/dataCatalog/findUserDatabases',
    method: 'get'
  })
}
export function findTablesReq(params: any): any {
  return axios({
    url: '/api-dataManage/dataCatalog/findTables',
    method: 'get',
    params
  })
}

export function updateDatabaseRemarkReq(params: any): any {
  return axios({
    url: '/api-dataManage/dataCatalog/updateDatabaseRemark',
    method: 'get',
    params
  })
}
export function updateTableRemarkReq(params: any): any {
  return axios({
    url: '/api-dataManage/dataCatalog/updateTableRemark',
    method: 'get',
    params
  })
}
export function updateDatabaseOwnerReq(params: any): any {
  return axios({
    url: '/api-dataManage/dataCatalog/updateDatabaseOwner',
    method: 'get',
    params
  })
}

export function updateTableOwnerReq(params: any): any {
  return axios({
    url: '/api-dataManage/dataCatalog/updateTableOwner',
    method: 'get',
    params
  })
}

export function getTableDetailReq(params: any): any {
  return axios({
    url: '/api-dataManage/tableManage/findTableDetail',
    method: 'get',
    params
  })
}
export function getUserPrivilegeReq(params: any): any {
  return axios({
    url: '/api-dataManage/privilegeManage/findUserPrivileges',
    method: 'get',
    params
  })
}

export function getProPrivilegeReq(params: any): any {
  return axios({
    url: '/api-dataManage/privilegeManage/findProjectPrivileges',
    method: 'get',
    params
  })
}

export function privilegeApplyReq(params: any): any {
  return axios({
    url: '/api-dataManage/privilegeManage/apply',
    method: 'get',
    params
  })
}
export function modUserPrivilegeReq(params: any): any {
  return axios({
    url: '/api-dataManage/privilegeManage/addUserPrivileges',
    method: 'get',
    params
  })
}
export function modProPrivilegeReq(params: any): any {
  return axios({
    url: '/api-dataManage/privilegeManage/addProjectPrivileges',
    method: 'get',
    params
  })
}
export function getDataTypeOptionsReq(params: any): any {
  return axios({
    url: '/api-dataManage/tableManage/findDataTypes',
    method: 'get',
    params
  })
}
export function getDataRelatedsReq(params: any): any {
  return axios({
    url: '/api-dataManage/tableManage/getTableDataRelateds',
    method: 'get',
    params
  })
}

export function getDataRelatedsDagReq(params: any): any {
  return axios({
    url: '/api-dataManage/tableManage/getTableDataRelatedsDag',
    method: 'get',
    params
  })
}

export function delDataRelatedReq(params: any): any {
  return axios({
    url: '/api-dataManage/tableManage/delTableDataRelated',
    method: 'get',
    params
  })
}

export function addDataRelatedReq(params: any): any {
  return axios({
    url: '/api-dataManage/tableManage/addTableDataRelated',
    method: 'get',
    params
  })
}

export function findDbsByDatasourceIdReq(params: any): any {
  return axios({
    url: '/api-dataManage/dataCatalog/findDatabasesByDatasourceId',
    method: 'get',
    params
  })
}
export function findTablesByDsAndDbReq(params: any): any {
  return axios({
    url: '/api-dataManage/dataCatalog/findTablesByDsAndDb',
    method: 'get',
    params
  })
}
